/**
 ####
 #重点buff 通过substring 转string
 ####
 StringBuffer 解决封装过多 对象太多的问题。
 StringBuffer 维护的是一个字节数组(可以转换成字符数组) 容量默认为16个字符,超出16 扩容公式为*2+2
 append方法只生成1个对象并且重载了多种数据类型。解决对象过多的问题。
 
 public StringBuffer()
 public StringBuffer(String str)
 public StringBuffer(CharSequence seq)
 public StringBuffer append(数据类型b）
 public StringBuffer delete(int start,int end)
 public int indexOf(String str)
 public StringBuffer insert(int offset,数据类型 b)
 public StringBuffer replace(int start,int end,String str)
 public String substring(int start,int end)
 public String substring(int start)
 public StringBuffer reverse()
 */

/*
package com.leo.第七章_常用类库api;

public class U7_L3_StringBuffer {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//stringbuff线程安全 。
//		String str="123";
//		String res=str+1+"123"+Test.buff();
//		char[] str_char={'1','?'};
//		System.out.println(res);
//		StringBuffer sb=new StringBuffer();
//		System.out.println(sb.length()+"\n"+sb.capacity());
//		sb.append(res).append(str_char).append(Test.buff()).delete(3, 4);
//		System.out.println(sb.length()+"\n"+sb.capacity()+"\n"+sb);
		
		//1.构造一个空的buff对象  容量16 字符0
//		public StringBuffer()
		StringBuffer sb=new StringBuffer();
		System.out.println("1.构造一个空的buff对象。\tsb的容量是: "+sb.capacity()+"\n\t\t\tsb的长度是: "+sb.length());
		
		//2.构造 用buff对象 接收一个字符串
//		public StringBuffer(String str)
		StringBuffer sb_str=new StringBuffer("this is a str.");
		System.out.println("2.构造sb_atr is: "+sb_str+"\n\t\t\tsb的容量是: "+sb_str.capacity()+"\n\t\t\tsb的长度是: "+sb_str.length());

		//3.3.构造 加入一个继承接口的其他数据类seq		
//		public StringBuffer(CharSequence seq)
		Seq seq=new Seq("this is seq");
		StringBuffer sb_seq=new StringBuffer(seq);
		System.out.println("3.构造 加入一个继承接口的其他数据类seq: "+sb_seq);
		
		//4.追加
//		public StringBuffer append(数据类型b）
		sb_seq.append("+").append(seq).append("+").append(seq);
		System.out.println("4.追加方法: "+sb_seq);
		
		//5.删除
//		public StringBuffer delete(int start,int end)
		sb_seq.append("+").append(seq).append("+").append(seq).delete(10, sb_seq.length()-1);
		System.out.println("5.删除方法: "+sb_seq);
		
		//6.字符串查询功能
//		public int indexOf(String str)
		int res_index=sb_seq.indexOf("is");
		System.out.println("6.字符串查询: "+res_index);
		
		//7.数据插入 接5->3
//		public StringBuffer insert(int offset,数据类型 b)
		sb_seq=sb_seq.insert(5, seq).insert(10, "is is seq seq").delete(22, sb_seq.length()-1).insert(sb_seq.length(), "!");
		System.out.println("7.数据插入: "+sb_seq);
		
		//8.指定范围替换
		//public StringBuffer replace(int start,int end,String str)
		sb_seq=sb_seq.replace(5, sb_seq.length()-1, "is seq");
		System.out.println("8.数据替换: "+sb_seq);
		
		//9.buff范围转字符串
//		public String substring(int start,int end)
		String str=sb_seq.substring(5, sb_seq.length()-1);
		System.out.println("9.转字符串: "+str);
		
		//10.buff指定头转字符串
//		public String substring(int start)
		String str_f=sb_seq.substring(5);
		System.out.println("10.指定头到尾转字符串: "+str_f);
		
		//11.反转 ->8
//		public StringBuffer reverse()
		sb_seq=sb_seq.reverse();
		System.out.println("11.反转: "+sb_seq);
	}

}

class Test{
	public static String buff() {
		return "buff";
	}
}

class Seq implements CharSequence{
	private final String value;
	public Seq(String value) {
		this.value=value;
	}
	@Override
	public int length() {
		// TODO Auto-generated method stub
		return value.length();
	}

	@Override
	public char charAt(int index) {
		// TODO Auto-generated method stub
		return value.charAt(index);
	}

	@Override
	public CharSequence subSequence(int start, int end) {
		// TODO Auto-generated method stub
		return value.subSequence(start, end);
	}
	@Override
	public String toString() {
		return value.toString();
	}	
}
*/



